package com.xb.cloud.service.client;

public class ServiceReturnUtils {

	public static boolean isSuccess(ServiceReturnInfo info) {
		if (info.getCode().equals(ServiceReturnCodes.SUCCESS.getCode())) {
			return true;
		}
		return false;
	}

	public static boolean isError(ServiceReturnInfo info) {
		if (info.getCode().equals(ServiceReturnCodes.SUCCESS.getCode())) {
			return false;
		}
		return true;
	}

	public static ServiceReturnInfo success() {
		ServiceReturnInfo info = new ServiceReturnInfo();
		info.setCode(ServiceReturnCodes.SUCCESS.getCode());
		return info;
	}

	public static ServiceReturnInfo success(Object data) {
		ServiceReturnInfo info = new ServiceReturnInfo();
		info.setCode(ServiceReturnCodes.SUCCESS.getCode());
		info.setData(data);
		return info;
	}

	public static ServiceReturnInfo error(ServiceReturnCodes code) {
		ServiceReturnInfo info = new ServiceReturnInfo();
		info.setCode(code.getCode());
		info.setMessage(code.getMsg());
		info.setDetailMessage(code.getDetail()); 
		return info;
	}
}
